package com.flurry.sdk;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

public final class lf<T> implements lg<List<T>> {
    lg<T> a;

    public lf(lg<T> lgVar) {
        this.a = lgVar;
    }

    public final void a(OutputStream outputStream, List<T> list) throws IOException {
        int i;
        if (outputStream != null) {
            AnonymousClass1 r2 = new DataOutputStream(outputStream) {
                public final void close() {
                }
            };
            if (list != null) {
                i = list.size();
            } else {
                i = 0;
            }
            r2.writeInt(i);
            for (int i2 = 0; i2 < i; i2++) {
                this.a.a(outputStream, list.get(i2));
            }
            r2.flush();
        }
    }

    /* renamed from: b */
    public final List<T> a(InputStream inputStream) throws IOException {
        if (inputStream == null) {
            return null;
        }
        int readInt = new DataInputStream(inputStream) {
            public final void close() {
            }
        }.readInt();
        ArrayList arrayList = new ArrayList(readInt);
        for (int i = 0; i < readInt; i++) {
            T a2 = this.a.a(inputStream);
            if (a2 == null) {
                throw new IOException("Missing record.");
            }
            arrayList.add(a2);
        }
        return arrayList;
    }
}
